package com.fjxd.city.mapper;


import com.fjxd.city.pojo.City;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author csw
 */
@Mapper
public interface CityMapper {
    /**
     * 返回所有城市信息
     * @return 返回所有城市数据
     */
    @Select("select * from city")
    List<City> getCityAll();

    /**
     * 通过id获取城市信息
     * @return 返回单个城市
     * @param id 输入城市id
     */
    @Select("select * from city where id = #{id}")
    City getCityById(Integer id);

    @Select("select id from city where name =#{cityName} limit 1")
    Integer getCityIdByName(String cityName);

    @Select("SELECT * from city where name = #{upCity} UNION ALL SELECT * from city where name = #{downCity} ")
    List<City> getCityIdListByName(String upCity,String downCity);

}
